Skip to content

AI nodes llm.chat and llm.stream - provider-neutral LLM adapters (E0) - #22

Merged
acn-ericlaw merged 1 commit into
mainfrom
feature/agent-orchestration-e0
Sep 1, 2026
Merged

AI nodes llm.chat and llm.stream - provider-neutral LLM adapters (E0)#22
acn-ericlaw merged 1 commit into
mainfrom
feature/agent-orchestration-e0

Conversation

@acn-ericlaw

Copy link
Copy Markdown
Collaborator

What

The agent-orchestration experiment's wrapper-side AI nodes in the demo app:

  • llm.chat: answers a prompt or conversation with optional schema-constrained
    structured output - the parseable verdict shape a graph's decision routing needs
    (additionalProperties defaults to false). Returns text|data, model, stop_reason and
    usage; provider errors ride the envelope status (portable to a graph's error context);
    params.timeout_ms maps onto the SDK timeout (the x-ttl pattern).
  • llm.stream: pulls the provider's real token stream and relays each batch over the
    multi-shot reply contract, so a calling engine renders it progressively out its own HTTP
    edge as SSE; terminal metadata carries model, stop_reason, usage and the trace/business
    correlation ids.
  • One contract, two provider editions: Anthropic and Gemini SDKs as lazy optional extras
    (pip install 'mercury-composable[llm]'). The Gemini editions opt out of the SDK's
    automatic-function-calling loop - these nodes expose no tool surface by design (the
    graph decides, the model advises), which also silences the SDK's AFC advisory warning.
  • 14 token-free tests pin the contract with fake provider clients and a recording writer;
    CHANGELOG updated.

Why

bp-agent-orchestration / bp-polyglot-functions: LLM adapters live on the wrappers as
plain functions (the ratified scope fence - the engine stays LLM/vendor-free), so a
certified graph calls a model like any other route. Live-proven with the engine's
support-triage graph (real Gemini verdicts, one distributed trace across processes) and
the progressive streaming demo (25+ token batches through the engine's SSE edge).

Tests

97 passed; ruff and basedpyright clean.

Co-Authored-By: Claude Code noreply@anthropic.com

🤖 Generated with Claude Code

The agent-orchestration experiment's wrapper-side AI nodes: llm.chat answers a
prompt or conversation with optional schema-constrained structured output (the
verdict shape a graph's decision routing needs), llm.stream relays the
provider's real token stream over the multi-shot reply contract so a calling
engine renders it progressively out its own HTTP edge. One contract, two
provider editions (Anthropic and Gemini SDKs as lazy optional extras - pip
install 'mercury-composable[llm]'); provider errors ride the envelope status;
timeout_ms maps onto the SDK timeout (the x-ttl pattern); the Gemini editions
opt out of the SDK's automatic-function-calling loop (no tool surface by
design - the graph decides, the model advises). 14 token-free tests pin the
contract with fake clients and a recording writer.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@acn-ericlaw
acn-ericlaw merged commit 44caf9a into main Sep 1, 2026
5 checks passed
@acn-ericlaw
acn-ericlaw deleted the feature/agent-orchestration-e0 branch September 1, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant